/* 
 * Copyright 2011 QDSS.org. All rights reserved.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.qdss.oapi4j;

import org.apache.http.Header;
import org.dom4j.Element;

import com.alibaba.fastjson.JSONObject;

/**
 * Api调用返回结果
 * 
 * @author <a href="mailto:zhaofang123@gmail.com">Zhao Fangfang</a>
 * @date 2011-3-20
 * @version $Id: Result.java 16 2011-04-03 09:59:57Z zhaofang123@gmail.com $
 * 
 * @param T xml:{@link Element} or json:{@link JSONObject}
 */
public interface Result<T> {

	/**
	 * 获取调用耗时（毫秒）
	 * 
	 * @return
	 */
	int getInvokeTime();
	
	/**
	 * 返回Headers
	 * 
	 * @return
	 */
	Header[] getHeaders();
	
	/**
	 * 是否有错误
	 * 
	 * @return
	 */
	boolean hasError();
	
	/**
	 * 错误描述
	 * 
	 * @return
	 */
	String getError();
	
	/**
	 * @return
	 */
	T rootValue();
	
	/**
	 * @return
	 */
	T nodeValue(String path);
	
	/**
	 * 是否有节点
	 * 
	 * @param path
	 * @return
	 */
	boolean hasValue(String path);
	
	/**
	 * 获取{@link Integer}值
	 * 
	 * @param path
	 * @return
	 */
	Integer getIntValue(String path);
	
	/**
	 * 获取{@link Long}值
	 * 
	 * @param path
	 * @return
	 */
	Long getLongValue(String path);
	
	/**
	 * 获取{@link Double}值
	 * 
	 * @param path
	 * @return
	 */
	Double getDoubleValue(String path);
	
	/**
	 * 获取{@link String}值
	 * 
	 * @param path
	 * @return
	 */
	String getStringValue(String path);
}
